package tt.dz.biz.job;

import java.lang.reflect.Method;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import tt.dz.biz.service.channel.ChannelCheckService;
import tt.dz.common.AppContxtUtil;
import tt.dz.common.DzConstants;
import tt.dz.common.DzConstants.sysJob;
import tt.dz.common.LogUtil;
import tt.dz.common.PayChannelAccountCheckEnum;

public class ChannelCheckJob
  extends AbstractJob
{
  protected void executeJob(JobExecutionContext context)
    throws JobExecutionException
  {
    ChannelCheckService channelCheckService = (ChannelCheckService)AppContxtUtil.getBean("channelCheckService");
    for (PayChannelAccountCheckEnum payChannelEnum : PayChannelAccountCheckEnum.values()) {
      if (!payChannelEnum.isDisable())
      {
        String checkImpMethodName = payChannelEnum.checkImpMethodName();
        try
        {
          Method checkImpMethod = ChannelCheckService.class.getMethod(checkImpMethodName, new Class[0]);
          checkImpMethod.invoke(channelCheckService, new Object[0]);
        }
        catch (Exception e)
        {
          LogUtil.error(payChannelEnum.channelName() + "执行渠道对账JOB发生异常", e);
        }
      }
    }
  }
  
  protected String getJobCode()
  {
    return DzConstants.sysJob.CHANNEL_CHECK_JOB.value();
  }
}
